{% extends "approval/base.html" %}
{% block title %} 申请审批 - {{ object.code }} {% endblock %}
{% block content %}
    <style>
        ul.errorlist li {
            color: red;
        }
    </style>
    <div class="col-lg-6 col-lg-offset-3">
        <section class="panel panel-default">
            <div class="panel-heading">
                申请审批 - {{ object.code }}
                {% if form.errors %}
                    <div style="color:red">
                        {{ form.errors }}
                        您提交的数据有误,请认真检查!
                    </div>
                {% endif %}
            </div>
            <div class="panel-body" style="padding: 10px;">
                <form class="form-horizontal" method="post" action="{{ request.path }}?t={{ request.GET.t }}&s={{ request.GET.s }}&g={{ request.GET.g }}"
                      enctype="multipart/form-data">
                    {% csrf_token %}
                    <input type="hidden" name="updated_by" id="id_updated_by" value="{{ request.user.id }}">
                    <section class="well">
                    <div class="form-group">
                        <div class="col-lg-2 control-label">申请人:</div>
                        <div class="col-lg-4">
                            <div class="form-control" readonly="readonly">{{ object.created_by.full_name }}</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.date_of_occurrence.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.date_of_occurrence }}
                            <p class="help-block">{{ form.date_of_occurrence.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.dates.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.dates }}
                            <p class="help-block">{{ form.dates.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.related_project.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.related_project }}
                            <p class="help-block">{{ form.related_project.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.related_department.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.related_department }}
                            <p class="help-block">{{ form.related_department.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.name.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.name }}
                            <p class="help-block">{{ form.name.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.initial_amount.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.initial_amount }}
                            <p class="help-block">{{ form.initial_amount.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.has_invoice.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.has_invoice }}
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.initial_notes.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.initial_notes }}
                            <p class="help-block">{{ form.initial_notes.errors }}</p>
                        </div>
                    </div>
                        <section class="attachments">
                        <legend style="font-size: 18px">附件</legend>
                        {% for attachment in object.attachments %}
                            <a href="{{ attachment.file.url }}">
                                <span class="btn btn-info" style="margin: 7px">
                                        {{ attachment.file_name }}
                                </span>
                            </a>
                        {% endfor %}
                    </section>
                    </section>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.related_application_type.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.related_application_type }}
                            <p class="help-block">{{ form.related_application_type.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.approval_amount.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.approval_amount }}
                            <p class="help-block">{{ form.approval_amount.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.status.label_tag }}</div>
                        <div class="col-lg-4">
                            <select name="status" class="selectpicker show-tick form-control" id="id_status">
                                <option value="3">审批通过</option>
                                <option value="5">审批未通过</option>
                            </select>
                            <p class="help-block">{{ form.status.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.approval_notes.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.approval_notes }}
                            <p class="help-block">{{ form.approval_notes.errors }}</p>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-lg-12" align="right">
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
{% endblock %}
{% block this_js %}
    <script>
        $('#id_date_of_occurrence').datepicker({language: "zh-CN"});
    </script>
{% endblock %}